package com.example.demo02.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <h3>xdpcp-service-api</h3>
 * <p></p>
 *
 * @author : fangxm
 * @date : 2022-04-19 21:29
 **/

@Configuration
public class SunlandConfig {

    public static String REDIS_PROJECTNAME;

    @Value("${sunland.common.redis_project}")
    public void setRedisprojectname(String redis_project) {
        REDIS_PROJECTNAME = redis_project;
    }

//    private ConfigurableApplicationContext context;
//
//    public static void main(String[] args) {
//        SpringApplication.run(YourApplication.class, args).close();
//    }
//
//    @Bean
//    public ApplicationListener<ApplicationReadyEvent> applicationListener() {
//        return event -> {
//            this.context = event.getApplicationContext();
//            Runtime.getRuntime().addShutdownHook(new Thread(this::closeContext));
//        };
//    }
//
//    private void closeContext() {
//        context.close();
//        SpringApplication.run(YourApplication.class);
//    }
}
